package com.mall.admin.controller;


import com.mall.admin.service.SmsHomeRecommendProductService;
import com.mall.commons.utils.R;
import com.mall.domain.SmsHomeRecommendProduct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/home/recommendProduct")
public class SmsHomeRecommendProductController {

    @Autowired
    private SmsHomeRecommendProductService smsHomeRecommendProductService;



    /**
     * 分页条件查询

     */
    @GetMapping("/list")
    public R findByPage(String brandName, Integer pageNum, Integer pageSize, Integer recommendStatus) {
        log.info("brandName="+brandName+"  pageNum="+pageNum+"   pageSize="+pageSize+"   recommendStatus="+recommendStatus);
        return smsHomeRecommendProductService.findByPage(brandName, pageNum, pageSize, recommendStatus);
    }


    //批量修改推荐品牌状态
    @PostMapping("/update/recommendStatus")
    public R updateRecommendStatus(@RequestParam("ids") List<Long> ids,@RequestParam("recommendStatus") Integer recommendStatus){
        return smsHomeRecommendProductService.updateRecommendStatus(ids,recommendStatus);
    }

    //添加首页推荐品牌
    @PostMapping("/create")
    public R addCreate(@RequestBody List<SmsHomeRecommendProduct> homeBrandList) {
        return smsHomeRecommendProductService.addCreate(homeBrandList);
    }

    //批量删除推荐品牌
    @PostMapping("/delete")
    public R delete(@RequestParam("ids") List<Long> ids) {
        return smsHomeRecommendProductService.delete(ids);
    }

    //修改推荐品牌排序
    @PostMapping("/update/sort/{id}")
    public R updateSort(@PathVariable Long id,Integer sort) {
        return smsHomeRecommendProductService.updateSort(id,sort);
    }

}
